﻿using System;
using System.Collections.Generic;
using GameFramework.Battle.Core;
using Gameplay.PVE.Utils;
using RootMotion.FinalIK;
using UnityEngine;

namespace Gameplay.PVE.Survivor
{
    public class TriggerElement: ElementBase
    {
        private float lastTriggerTime = -1;
        public override void Execute()
        {
            lastTriggerTime = -1;
        }

        public override void Update()
        {
            if (lastTriggerTime < 0 || TimeManager.time - lastTriggerTime >= config.trigger_interval)
            {
                AddSubElement();
                lastTriggerTime = TimeManager.time;
            }
        }

        private void AddSubElement()
        {
            target.AddElement((int)config.trigger_effect,source,bullet);
        }

        public override void OnFree()
        {
            
        }

        public override bool IsImmediate()
        {
            return false;
        }
    }
}
